//
//  SearchMainTextField.m
//  NewYzwShop
//
//  Created by DLS-MACMini on 2017/8/18.
//  Copyright © 2017年 xmzyqf. All rights reserved.
//

#import "customTextField.h"

@interface customTextField ()

@end
@implementation customTextField

-(instancetype)initWithFrame:(CGRect)frame leftImagePath:(NSString *)path PlaceHolder:(NSString *)placeHolder{
    if (self = [super initWithFrame:frame]) {
        [self initUIWithImagePath:path placeHolder:placeHolder];
    }
    return self;
}
-(void)initUIWithImagePath:(NSString *)path placeHolder:(NSString *)placeHolder{
    self.placeholder = placeHolder;
    self.borderStyle = UITextBorderStyleRoundedRect;
    self.returnKeyType = UIReturnKeyNext;
    self.keyboardType = UIKeyboardTypeDefault;
    self.textAlignment = NSTextAlignmentLeft;
    self.font = FONT(14);
    self.textColor = UIColorFromRGB(0x666666);
    self.clearButtonMode = 0;
    self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    
    UIView *leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 30)];
    leftView.backgroundColor = [UIColor clearColor];
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(8, (30 - 13) / 2.0, 12, 13)];
    imageView.image = [UIImage imageNamed:path];
    [leftView addSubview:imageView];
    
    self.leftView = leftView;
    self.leftViewMode = UITextFieldViewModeAlways;
}
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
    }
    return self;
}
-(void)initUI{
    self.placeholder = @"搜索商城商品";
    self.borderStyle = UITextBorderStyleRoundedRect;
    self.returnKeyType = UIReturnKeySearch;
    self.keyboardType = UIKeyboardTypeDefault;
    self.textAlignment = NSTextAlignmentLeft;
    self.font = FONT(14);
    self.textColor = UIColorFromRGB(0x666666);
    self.clearButtonMode = 0;
    self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    
    UIView *leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 30)];
    leftView.backgroundColor = [UIColor clearColor];
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(8, (30 - 13) / 2.0, 12, 13)];
    imageView.image = [UIImage imageNamed:@"searchHome.png"];
    [leftView addSubview:imageView];
    
    self.leftView = leftView;
    self.leftViewMode = UITextFieldViewModeAlways;
}

@end
